<include file="Public/header" />
<body onselectstart="return false">
<div class="main FromUpToDown" >
    <div class="content" style="position: relative">
        <div class="head-content">
            <div class="head-title">
                <span><{:ACTION_NAME == 'edit' ? '修改' : '添加'}>短信模板</span>
            </div>
        </div>
        <form action='' id="form" >
            <input type="hidden" name="id" value="<{$info['id']}>">
            <div class="form-content">
                <div class="form">
                    <div class="form-left">用户</div>
                    <div class="form-right">
                        <select class="form-input-small" name="user_id" >
                            <foreach name="user" item="vo">
                                <option value="<{$vo['id']}>"><{$vo['name']}></option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form">
                    <div class="form-left">语音总量</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='capacity'  value="<{$info['capacity']}>" placeholder="语音总量"  />
                    </div>
                </div>
                <div class="form-operate">
                    <button type='button' id="save"  class="form-button color-bg-green">保存</button>
                    <button type='button' onclick="history.go(-1)" class="form-button color-bg-grey">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<include file="Public/footer"  />
<script>
    $("#save").click(function(){

        if($("input[name='user_id']").val() == ''){
            layer.tips('请选择用户！', 'input[name="user_id"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        if($("input[name='capacity']").val() == ''){
            layer.tips('请输入短信容量！', 'input[name="capacity"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        $("#save").attr('disabled',true);
        $.post(
                "<{:U('save')}>",
                $("#form").serialize(),
                function(res){
                    if(res.status == 1){
                        layer.tips(res.info, '#save', {tips: [2, 'green'], time: 1000});
                        setTimeout("location.href = document.referrer",1000);
                    }else{
                        $("#save").attr('disabled',true);
                        layer.tips(res.info, '#save', {tips: [2, 'red'], time: 1000});
                    }
                }
        );
    });
</script>
</body>
</html>